<?php

namespace frontend\models;

use Yii;
use common\helpers\Url;

/**
 * 帮助模型
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class HelpSearch extends \common\models\Help {

    /**
     * 学校精品课程
     * @param array $id 学校ID
     * @return ActiveDataProvider
     */
    public function search() {
        return static::find()
        ->select(['id', 'title', 'created_at'])
        ->where(['status' => static::STATUS_ACTIVE])
        ->orderBy([
            'listorder' => SORT_ASC,
            'created_at' => SORT_DESC
        ])
        ->cache(5)
        ->all();
    }

    public function fields() {
        return [
            'id',
            'title',
            'content',
            'thumb' => function () {
                return Url::toRemote($this->thumb);
            },
            'created_at' => function () {
                return date('Y-m-d', $this->created_at);
            }
        ];
    }

}
